package com.quartz;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;

/**
 * Created by Administrator on 2018-9-12 0012.
 */
public class QuartzJobFactory extends AdaptableJobFactory {

    @Autowired
    private AutowireCapableBeanFactory capableBeanFactory;

    protected Object createJobInstance(TriggerFiredBundle triggerFiredBundle) throws Exception {
        Object jobInstance = super.createJobInstance(triggerFiredBundle);
        capableBeanFactory.autowireBean(jobInstance);
        return jobInstance;
    }

}
